import pymysql

conn = pymysql.connect(
    host='172.16.5.157',
    user='root',
    password='pwerd@2021',
    database='findfit_admin'
)

cursor = conn.cursor(cursor=pymysql.cursors.DictCursor)
sql = 'select * from sys_menu'

affect_rows = cursor.execute(sql)  # 返回sql影响的行数
print(affect_rows)

# r = cursor.fetchone()   # 从当前位置拿到一条执行结果
# cursor.fetchall()   # 拿到所有结果
r = cursor.fetchmany(5)  # 获取前几个结果
print(r)
